
import * as BaseApi from './BaseApi.js';

import * as Config from './Config.js';




//查询车型分组
// export const updateMerchantInfo = (model) => {

//        return BaseApi.requestForm(Config.g_biz_url, '/car/group/query', model)
//            .then(res => res)
//    }


//上传图片
export const upLoadPicture = (form) => {

    return BaseApi.requestBody(Config.g_upload_url, form, {
        method: 'post',
        headers: { 'Content-Type': 'multipart/form-data' }
    })
        .then(res => res)
}


//修改商户信息
export const updateMerchantInfo = (self,model) => {
    Object.assign(model, {
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId
    });

    
    return BaseApi.requestForm(Config.g_biz_url, '/supplier/update', model)
        .then(res => res)
}

//获取商户信息
export const getMerchantInfo = (self) => {

    return BaseApi.requestForm(Config.g_biz_url, '/supplier/info/bysupplier', {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    })
        .then(res => res)
}

//登录
export const doLogin = (model) => {
    return BaseApi.requestForm(Config.g_biz_url, '/auth/merchant/login', model)
        .then(res => res)
}


//自定义属性取消匹配车型
export const cancelMaintainLinkCar = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linkdelete', model)
        .then(res => res)
}



//自定义属性匹配车型
export const maintainLinkCar = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linkadd', model)
        .then(res => res)
}


//修改自定义属性
export const editInfoEditForm = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/update', model)
        .then(res => res)
}

//新增自定义属性
export const addInfoEditForm = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/add', model)
        .then(res => res)
}


//属性ID查询绑定的所有车型
export const getCarIdListBymaintainId = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linklist', model)
        .then(res => res)
}
//初始化筛选字段
export const initFilterList = () => {
    return BaseApi.requestForm(Config.g_service_url, '/screeninit')
        .then(res => res)
}


//分组详情
export const MaintainDatil = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/query', model)
        .then(res => res)
}

//修改分组
export const MaintainUpdate = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/update', model)
        .then(res => res)
}


//添加分组
export const MaintainAdd = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/add', model)
        .then(res => res)
}



//查询维护信息栏目
export const getMaintainList = (self, model) => {

    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/list', model)
        .then(res => res)
}


//获取品牌列表
export const getBrandList = () => {

    return BaseApi.requestForm(Config.g_service_url, '/brandlist')
        .then(res => res)
}
//通过BrandID获取车系列表
export const getSeriesList = (brandId) => {
    return BaseApi.requestForm(Config.g_service_url, `/serieslist?brandId=${brandId}`)
        .then(res => res)
}
//通过品牌、车系ID 获取年份列表
export const getBsmList = (self, model) => {
    Object.assign(model, {
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_service_url, '/bsm', model)
        .then(res => res)
}
//通过车型ID获取车型信息
export const getModelItemByModelId = (self, model) => {
    Object.assign(model, {
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_service_url, '/bsm', model)
        .then(res => res)
}


//订单
export const getOrderList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/queryorder', model)
        .then(res => res)
}

// 挂单
export const getAccountList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/queryOrderOnAccount', model)
        .then(res => res)
}
// 切换订单状态
export const changeStatus = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/changeStatus', model)
        .then(res => res)
}





//会员列表

export const getUserList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/query', model)
        .then(res => res)
}
//发货
export const updateSendgoods = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/transport/update', model)
        .then(res => res)
}

//发货
export const doSendgoods = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/sendgoods', model)
        .then(res => res)
}
//删除栏目

export const delColumn = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/column/delete', model)
        .then(res => res)
}
//删除维保
export const delMainTain = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/delete', model)
        .then(res => res)
}

//查询等级价格
export const getDiscountList = (self) => {
    return BaseApi.requestForm(Config.g_biz_url, '/user/discount/query', {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    })
        .then(res => res)
}

//修改等级价格
export const updateDiscount = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/discount/save', model)
        .then(res => res)
}

//修改属性
export const editAttribute = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/update', model)
        .then(res => res)
}

//删除属性
export const delAttribute = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/delete', model)
        .then(res => res)
}




//查询已选择的车型
export const querySelectCar = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintaingroup/car/linkquery', model)
        .then(res => res)
}


//分组匹配车型
export const groupLinkCarByTemp = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintaingroup/car/linkaddbytemp', model)
        .then(res => res)
}

//分组匹配车型
export const groupLinkCar = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintaingroup/car/linkadd', model)
        .then(res => res)
}
//取消分组匹配车型
export const delgroupLinkCar = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintaingroup/car/linkdelete', model)
        .then(res => res)
}
//删除分组
export const delGroup = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/delete', model)
        .then(res => res)
}


//用户等级修改
export const userIndexPrice = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/updatelevel', model)
        .then(res => res)
}
//属性排序

export const attributeSort = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/sort', model)
        .then(res => res)
}

//修改用户状态
export const updateUserStatus = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/check', model)
        .then(res => res)
}

//冻结用户
export const doblockStatus = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/block', model)
        .then(res => res)
}
//消费表
export const transactionList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/transaction/query', model)
        .then(res => res)
}

//商户账户
export const getAccount = (self) => {

    return BaseApi.requestForm(Config.g_biz_url, '/merchant/transaction/account', {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    })
        .then(res => res)
}

//商户收入走势

export const getTrend = (self) => {
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/transaction/trend', {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    })
        .then(res => res)
}
//修改密码
export const changPassword = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/password/update', model)
        .then(res => res)
}

//接受退款
export const acceptRefund = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/refund/accept', model)
        .then(res => res)
}

//拒绝退款
export const aconRefund = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/refund/refuse', model)
        .then(res => res)
}
//用户消费记录
export const getMoneyModel = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/transaction/query', model)
        .then(res => res)
}

//查询物流接口
export const getShipList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/transport/merchantquery', model)
        .then(res => res)
}


//订单详情

export const getDetil = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/queryorderdetail', model)
        .then(res => res)
}

//查询使用声明
export const getStatement = (self) => {
    return BaseApi.requestForm(Config.g_biz_url, '/statement/query', { merchantId: self.$store.getters.getMerchantId })
        .then(res => res)
}

//新增使用声明
export const addStatement = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/statement/add', model)
        .then(res => res)
}


//跟新使用声明
export const updateStatement = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/statement/update', model)
        .then(res => res)
}


//新增热词
export const addHotword = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/hotword/add', model)
        .then(res => res)
}
//查询热词
export const getHotword = (self) => {
    return BaseApi.requestForm(Config.g_biz_url, '/hotword/query', { merchantId: self.$store.getters.getMerchantId })
        .then(res => res)
}
//删除热词
export const delHotword = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/hotword/delete', model)
        .then(res => res)
}
//获取维修记录列表
export const getRecordList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintenance/record/list', model)
        .then(res => res)
}
//VIN查询
export const getCarByVin = (self, model) => {
    Object.assign(model, {
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/vin/qurey', model)
        .then(res => res)
}
//添加维修记录
export const addRecord = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintenance/record/add', model)
        .then(res => res)
}

//修改维修记录
export const updateRecord = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintenance/record/update', model)
        .then(res => res)
}
//获取商户角色
export const getMerchantRole = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/role/list', model)
        .then(res => res)
}
//修改商户角色
export const updateMerchantRole = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/role/update', model)
        .then(res => res)
}


//新增商户角色
export const addMerchantRole = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/role/add', model)
        .then(res => res)
}

//商户用户列表
export const getSysUserList = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/user/list', model)
        .then(res => res)
}

//角色查权限
export const roleGetPermission = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/rolepermission/list', model)
        .then(res => res)
}

//删除商户用户
export const delMerchantUser = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/user/delete', model)
        .then(res => res)
}

//添加商户用户
export const addMerchantUser = (self, model) => {
    let local = localStorage
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId,
        merchantCode: local.merchantCode
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/user/add', model)
        .then(res => res)
}



//修改商户用户
export const updateMerchantUser = (self, model) => {
    let local = localStorage
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        merchantId: self.$store.getters.getMerchantId,
        merchantCode: local.merchantCode
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/user/update', model)
        .then(res => res)
}
//管理员修改用户信息
export const updateMerchantUser1 = (self, model) => {
    let local = localStorage
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId,
        // merchantId: self.$store.getters.getMerchantId,
        merchantCode: local.merchantCode
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchantuser/user/updatebyadmin', model)
        .then(res => res)
}

//更新角色权限
export const roleUpdatePermission = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/merchant/rolepermission/update', model)
        .then(res => res)
}
//注册用户
export const addUserSave = (self, model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantUserId: self.$store.getters.getModel.merchantUserId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/add', model)
        .then(res => res)
}
// 

export const getProvince = (self,model) => {
    
    return BaseApi.requestForm(Config.g_biz_url, '/address/queryprovince', model)
        .then(res => res)
}

export const getQueryCity = (self,model) => {
    
    return BaseApi.requestForm(Config.g_biz_url, '/address/querycity', model)
        .then(res => res)
}
